From 4c2dd6e0ea9b3dcf1cbf5bd176e6044017288584 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Fri, 4 May 2007 20:02:05 +0000 Subject: [PATCH] xcsv: Add support for BNG (British National Grid) coordinates. --- csv_util.c | 16 +++++++++++++++- xmldoc/chapters/styles.xml | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/csv_util.c b/csv_util.c index a1a7edf87..047a453dd 100644 --- a/csv_util.c +++ b/csv_util.c @@ -881,7 +881,11 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) if (strcmp(fmp->key, "LON_DIR") == 0) { /* longitude E/W. Ingore on input for now */ } else - + /* SPECIAL COORDINATES/GRID */ + if (strcmp(fmp->key, "MAP_EN_BNG") == 0) { + parse_coordinates(s, DATUM_OSGB36, grid_bng, + &wpt->latitude, &wpt->longitude, MYNAME); + } else /* ALTITUDE CONVERSIONS ************************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { /* altitude in feet as a decimal value */ @@ -1348,6 +1352,16 @@ xcsv_waypt_pr(const waypoint *wpt) writebuff(buff, fmp->printfc, LON_DIR(lon)); } else + + /* SPECIAL COORDINATES */ + if (strcmp(fmp->key, "MAP_EN_BNG") == 0) { + char map[3]; + double north, east; + if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) + fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n", + wpt->latitude, wpt->longitude); + snprintf(buff, sizeof(buff), fmp->printfc, map, (int)(east + 0.5), (int)(north + 0.5)); + } else /* ALTITUDE CONVERSIONS**********************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { diff --git a/xmldoc/chapters/styles.xml b/xmldoc/chapters/styles.xml index 3f64a1d10..4bd2f3835 100644 --- a/xmldoc/chapters/styles.xml +++ b/xmldoc/chapters/styles.xml @@ -646,6 +646,24 @@ examples: +
+MAP_EN_BNG + + MAP_EN_BNG converts coordinates from/to British National Grid (BNG). + + + The only supported order of the items is: Map,Easting,Northing. + During output all coordinates have to be located within this limited area. + + +examples: + + + IFIELD MAP_EN_BNG,"","%s%5d %5d" # (writes i.e. "SJ00001 00001") + IFIELD MAP_EN_BNG,"","%s %d %d" # (writes i.e. "TQ 888 999") + +
+
LON_HUMAN_READABLE -- 2.30.2